package com.tiantianyuegou.adapter;

import android.app.Activity;
import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.trouble.framework.adapter.BaseAdapterHelper;
import com.trouble.framework.adapter.QuickAdapter;
import com.tiantianyuegou.R;

/**
 * 
 *@Title:首页模块adapter
 *@Description:
 *@Author:trouble
 *@Since:2015-9-1
 *@Version:1.1.0
 */
public class CategoryModularGridAdapter extends QuickAdapter<CategoryModularGridAdapter.GlobalMenuItem> {

	public CategoryModularGridAdapter(Context context) {
		super(context, R.layout.grid_item_shouye_modular);
		data.add(new CategoryModularGridAdapter.GlobalMenuItem(R.mipmap.new_goods, "新品上市", null));
		data.add(new CategoryModularGridAdapter.GlobalMenuItem(R.mipmap.highquality_special, "优质特产", null));
		data.add(new CategoryModularGridAdapter.GlobalMenuItem(R.mipmap.boutique_promotion, "精品促销",null));
		data.add(new CategoryModularGridAdapter.GlobalMenuItem(R.mipmap.grab_redbag, "抢红包", null));
		//data.addAll(datas);
	}

	@Override
	protected void convert(BaseAdapterHelper helper, GlobalMenuItem item) {
		ImageView image = helper.getView(R.id.iv_modular_icon);
		TextView text = helper.getView(R.id.tv_modular_name);
		image.setImageResource(item.iconResId);
		text.setText(item.label);
	}

	public static class GlobalMenuItem {
		public int iconResId;
		public String label;
		public Class<? extends Activity> clazz;

		public GlobalMenuItem(int resId, String label) {
			this.iconResId = resId;
			this.label = label;
		}

		public GlobalMenuItem(int resId, String label, Class<? extends Activity> clazz) {
			this.iconResId = resId;
			this.label = label;
			this.clazz = clazz;
		}
	}
}
